const mongoose = require("mongoose");
const baseModel = require("./baseModel");
const md5password = require("../utils/md5");
const userModel = new mongoose.Schema({
  username: {
    type: String,
    required: true,
  },
  email: {
    type: String,
    required: true,
  },
  password: {
    type: String,
    required: true,
    set: (value) => md5password(value),
    select: false, //设置了false 则查询结果不会将password字段数据返回
  },
  phone: {
    type: String,
    required: true,
  },
  image: {
    type: String,
    default: null,
  },
  cover: {
    type: String,
    default: null,
  },
  channeldes: {
    type: String,
    default: null,
  },
  subscribeCount: {
    type: Number,
    default: 0,
  },
  ...baseModel,
});

module.exports = userModel;
